package zzzhc.image.recognize.filter;

import java.util.List;

import zzzhc.image.recognize.Filter;
import zzzhc.image.recognize.ImageToken;
import zzzhc.image.recognize.RecognizeContext;
import zzzhc.image.recognize.TokenUtil;

public class NormalizeFilter implements Filter {

	private static final long serialVersionUID = 7500409341395552860L;

	private int width = 9;

	private int height = 9;

	private double emptyRatio = 0.5;

	public void doFilter(RecognizeContext context) {
		List<ImageToken> tokens = context.getTokens();
		ImageToken[] result = new ImageToken[tokens.size()];
		for (int i = 0; i < result.length; i++) {
			result[i] = TokenUtil.convert(tokens.get(i), width, height,
					emptyRatio);
		}
		context.clearTokens();
		context.addTokens(result);
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public double getEmptyRatio() {
		return emptyRatio;
	}

	public void setEmptyRatio(double emptyRadio) {
		this.emptyRatio = emptyRadio;
	}

}
